package ex.datastream.connectors;


import ex.datastream.functions.function.FlatMapFuncBySplitter02;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 示例：基于socketTextStream读取数据源
 * windows,cmd命令
 * C:\Users\Administrator>nc -lp 9999
 */
public class SocketTest {

    public static void main(String[] args) throws Exception {
        final StreamExecutionEnvironment env =
                StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<String> text=env.socketTextStream("localhost",9999,"\n");

        DataStream<Tuple2<String, Integer>> person=text .flatMap(new FlatMapFuncBySplitter02());

        person.print();

        env.execute();
    }


}